home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _A39DD656C739442EA400D2C15A29A658 < prev    next >
Text File  |  2005-01-29  |  2KB  |  70 lines

  1. //pixel shader to sample texture and environment map and mixes with material color
  2. //combines a fixed bump image with a procedurally generated one for tiny ripples
  3. //has projective reflections
  4. //Luke Lenhart
  5. //(C)2004-2005 Digipen Institute of Technology
  6.  
  7. //time since whenever
  8. float time;
  9.  
  10. //magnitude of ripples (recommend from 0.75f to 1.5f)
  11. float ripMag;
  12.  
  13. //base texture
  14. sampler sampTex;
  15.  
  16. //cube texture
  17. sampler sampCube;
  18.  
  19. //projective reflection texture
  20. sampler sampProjRefl;
  21.  
  22. //
  23. struct PS_INPUT
  24. {
  25.     float2 Tex0 : TEXCOORD0;
  26.     float3 EnvTex : TEXCOORD1;
  27.     float4 Clr : COLOR;
  28.     float3 Pos : TEXCOORD2;
  29.     float4 ProjTxt : TEXCOORD3;
  30. };
  31.  
  32. float4 PShader(PS_INPUT In) : COLOR
  33. {
  34.     //calc wave offset 0 and 1
  35.     float3 tmpW0sin, tmpW0cos;
  36.     sincos(float3(4.0f,4.0f,4.0f)*time+In.Pos,tmpW0sin,tmpW0cos);
  37.  
  38.     float3 normWave0=0.17f*(tmpW0sin+tmpW0cos);
  39.     float3 normWave1=sin(tmpW0sin*tmpW0cos+In.Pos.x+In.Pos.y);
  40.  
  41.     //combine waves    
  42.     float3 normWaveCombined=ripMag * normWave0 * normWave1;
  43.     
  44.     //calc proj text warp
  45.     float4 projTxtWaved=In.ProjTxt;
  46.     float2 projMod=sin(float2(13.0f,5.0f)*time+.6f*In.Pos.xy)*float2(0.75f,0.025f);
  47.     projTxtWaved.xy=In.ProjTxt.xy+projMod;
  48.     
  49.     //calc normal offset for sampling
  50.     float3 normOff=normWaveCombined;
  51.     
  52.     //combine env map, color map sample, and projective texture sample
  53.     float4 clrPlain=tex2D(sampTex,-0.5f*float3(time,time,time)+In.Tex0);
  54.     float4 clrEnv=texCUBE(sampCube,normOff+In.EnvTex);
  55.     float4 clrProjRefl=tex2Dproj(sampProjRefl,projTxtWaved);
  56.     
  57.     float4 clr=0.33f*clrPlain + 0.85f*clrEnv + 0.6f*clrProjRefl;
  58.     
  59.     //apply vert color
  60.     clr*=In.Clr;
  61.     
  62.     //temp
  63.     clr.xyz=clr.xyz*0.01f+normWaveCombined*5;
  64.     
  65.     //set alpha from vert color
  66.     clr.a=In.Clr.a;
  67.     
  68.     return clr;
  69. }
  70.